{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import ollama"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "There are a few bugs in this code:\n",
      "\n",
      "1. The base case is not handled correctly. The function should return `0` if `n == 0`, but it returns `n` instead.\n",
      "2. The recursive calls are not correct. The function should call `fib(n-1)` and `fib(n-2)`, but it calls `fib(n-1)` and `fib(n-3)` instead.\n",
      "\n",
      "Here is the corrected code:\n",
      "```\n",
      "def fib(n):\n",
      "    if n <= 0:\n",
      "        return 0\n",
      "    elif n == 1:\n",
      "        return 1\n",
      "    else:\n",
      "        return fib(n-1) + fib(n-2)\n",
      "```\n"
     ]
    }
   ],
   "source": [
    "response = ollama.chat(model='codellama:7b', messages=[\n",
    "  {\n",
    "    'role': 'user',\n",
    "    'content': '''\n",
    "    Where is the bug in this code?\n",
    "\n",
    "    def fib(n):\n",
    "        if n <= 0:\n",
    "            return n\n",
    "        else:\n",
    "            return fib(n-1) + fib(n-2)\n",
    "    ''',\n",
    "  },\n",
    "])\n",
    "print(response['message']['content'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "response = ollama.chat(model='codellama:70b', messages=[\n",
    "  {\n",
    "    'role': 'user',\n",
    "    'content': '''\n",
    "    Where is the bug in this code?\n",
    "\n",
    "    def fib(n):\n",
    "        if n <= 0:\n",
    "            return n\n",
    "        else:\n",
    "            return fib(n-1) + fib(n-2)\n",
    "    ''',\n",
    "  },\n",
    "])\n",
    "print(response['message']['content'])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "ollama-poc",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
